package com.lhh.userservice.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lhh.springcommon.annotation.WebLog;
import com.lhh.springcommon.annotation.WithRequestId;
import com.lhh.springcommon.entity.*;
import com.lhh.springcommon.entity.vo.CountUserInfoVO;
import com.lhh.springcommon.entity.vo.UserVO;
import com.lhh.springcommon.entity.vo.VideoVO;
import com.lhh.springcommon.utils.PageQuery;
import com.lhh.springcommon.utils.Response;
import com.lhh.userservice.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户个人中心
 * @author 李厚航
 * @date 2025-02-25
 */
@RestController
@RequestMapping("/personalCenter")
public class PersonalCenterController {

    private final UserCollectService userCollectService;

    private final UserLikeService userLikeService;

    private final UserHistoryService userHistoryService;

    private final UserFollowService userFollowService;

    private final UserCommentService userCommentService;

    private final UserPublishService userPublishService;

    @Autowired
    public PersonalCenterController(UserCollectService userCollectService,
                                    UserLikeService userLikeService,
                                    UserHistoryService userHistoryService,
                                    UserFollowService userFollowService,
                                    UserCommentService userCommentService,
                                    UserPublishService userPublishService) {
        this.userCollectService = userCollectService;
        this.userLikeService = userLikeService;
        this.userHistoryService = userHistoryService;
        this.userFollowService = userFollowService;
        this.userCommentService = userCommentService;
        this.userPublishService = userPublishService;
    }

    /**
     * 查询用户发布数
     * @return 用户发布数
     */
    @GetMapping("/countPublish")
    @WithRequestId
    @WebLog
    public Response<Long> countPublish(@RequestParam("uid") Integer uid){
        return Response.success(userPublishService.countPublish(uid));
    }

    /**
     * 获取用户关注数，粉丝数，发布数，收藏数
     * @return
     */
    @GetMapping("/countInfoByUser")
    @WithRequestId
    @WebLog
    public Response<CountUserInfoVO> countInfoByUser(){
        return Response.success(userPublishService.countInfoByUserId());
    }

    /**
     * 更新用户信息
     * @param user
     * @return
     */
    @PutMapping("/updateUserInfo")
    @WithRequestId
    @WebLog
    public Response<Boolean> updateUserInfo(@RequestBody User user){
        return Response.success(userPublishService.updateUserInfo(user));
    }
}
